import mypysql
from threading import Lock

sqlLock= Lock()

class Locked_mypysql:
    def __init__(self, host, db, user, passw, port= 0):
        mypysql.setAccess(db, host, user, passw, port)
        mypysql.setOptions(1)
        
    def execute(self, stm):
        with sqlLock:
            return mypysql.execute(stm)
            
    def query(self, slot, stm):
        with sqlLock:
            return mypysql.query(slot, stm)
    
    field= mypysql.field
    rows= mypysql.rows
    eor= mypysql.eor
    next= mypysql.next

    def test(self):
        if mypysql.open() :
            return False
            
        return not mypysql.close()

__all__= [ 'Locked_mypysql' ]        
